package fileUpload;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;

// 文件上传
public class FileUpload {
    ChromeDriver driver = new ChromeDriver();

    @Test
    public void test() throws InterruptedException {
        // 找到相关的 input 标签之后，sendKeys 文件路径就好了
        driver.get("file:///D:/MyJavaCode/Typora%E7%AC%94%E8%AE%B0/%E6%B5%8B%E5%BC%80/selenium-html/upload.html");
        Thread.sleep(1000);
        // 输入文件路径
        String path = "D:\\MyJavaCode\\Typora笔记\\测开\\selenium-html\\upload.html";
        Thread.sleep(1000);
        // 找到相关的 input 标签
        driver.findElement(By.cssSelector("body > div > div > input[type=file]")).sendKeys(path);
        Thread.sleep(1000);

        driver.quit();
    }
}
